#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#第1行注释可以让这个hello.py文件直接在Unix/Linux/Mac上运行，
#第2行注释表示.py文件本身使用标准UTF-8编码：
import requests
from lxml import etree
class Spider(object):
    def start_request(self):
        url=r'https://ibaotu.com/shipin/'
        r=requests.get(url)
        content=r.content.decode()
        html=etree.HTML(content)
        src_list=html.xpath('//div[@class="video-play"]/video/@src')
        title_list=html.xpath('//span[@class="video-title"]/text()')
        self.xpath_data(src_list,title_list)
    def xpath_data(self,src_list,title_list):
        for src,tit in zip(src_list,title_list):
            content=requests.get("http:"+src).content
            filename=tit+".mp4"
            print("正在爬取："+filename)
            #with open(filename,"wb") as f:
            #    f.write(content)
spider=Spider()
spider.start_request()